package com.ruoyi.common.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.mybatisflex.annotation.Column;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.IdToName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Entity基类
 *
 * @author ruoyi
 */
@Data
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 搜索值
     */
    @JsonIgnore
    @Column(ignore = true)
    private String searchValue;

    /**
     * 删除标志（0代表存在 1代表删除）
     */
    @JsonIgnore
    @Column(isLogicDelete = true)
    private Integer delFlag;

    /**
     * 创建者
     */
//    @Column(onInsertValue = "IFNULL(#item, T(com.ruoyi.common.utils.SecurityUtils).getUserId())")
    private String createBy;




    /**
     * 创建时间
     */
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//    @Column(onInsertValue = "NOW()")
    private Date createTime;

    /**
     * 更新者
     */
//    @Column(onUpdateValue = "T(com.ruoyi.common.utils.SecurityUtils).getUsername()")
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//    @Column(onUpdateValue = "NOW()")
    private Date updateTime;

    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @Column(ignore = true)
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }



/*
    /// 创建者
    @IdToName(type = Translate.Type.USER, async = false, nameField = "createName")
    private String createBy;

    @Column(ignore = true)
    private String createName;
*/


}
